//Create a TableView with custom layout.  
//This hack allows me to control the color of labels in the TableView 

var viewTable = Ti.UI.createTableView({
	top: 60,
	height: 210,
	width: 220,
	separatorStyle: 0,
	separatorColor:'transparent' 
});

var CustomData = [
{ icon:'images/groups_icon', label:"user groups",hasChild:false, window: 'usergroup.js' },
{ icon:'images/forums_icon', label:"forums", disabled: true, hasChild:false },
{ icon:'images/blogs_icon', label:"blogs", hasChild:false, window: 'blog.js' },
{ icon:'images/contri_icon', label:"active contributors", disabled: true, hasChild:false }

];

var data=[];

for (var i = 0; i < CustomData.length; i++){

	var row = Ti.UI.createTableViewRow();
	var icon = Ti.UI.createImageView({
		image: CustomData[i].icon + (CustomData[i].disabled ?  '_disabled.png' : '.png' ),
		height: 50,
		width: 50,
		left: 0,
		top: 0
	});
	
	row.add(icon);
	
	var label = Ti.UI.createLabel({
		text:CustomData[i].label,
		font:{fontSize:16,fontWeight:'bold'},
		color: CustomData[i].disabled ?  '#777' : DotNetNuke.linkColor,
		width:'auto',
		textAlign:'left',
		top:10,
		left:60,
		height:25
	});
	
	row.add(label);
	row.height=50;
	row.label=CustomData[i].label;
	row.hasChild=CustomData[i].hasChild;
	row.window=CustomData[i].window;
	row.className = 'button_row';

	data.push(row);
};

viewTable.setData(data);

// create table view event listener
viewTable.addEventListener('click', function(e)
{
	if (e.rowData.window && !e.rowData.disabled)
	{
		var win = null;
		if (Ti.Platform.name == "android") {
			win = Ti.UI.createWindow({
				url:e.rowData.window,
			    backgroundImage:DotNetNuke.getBackgroundImage(),
				navBarHidden: true 
			});	
		} else {
			win = Ti.UI.createWindow({
				url:e.rowData.window,
			    backgroundImage:DotNetNuke.getBackgroundImage(),
				barColor:'#111'		
			});
		}
		
		if (e.index == 3)
		{
			win.hideTabBar();
		}
		win.close();
		win.open();//{modal:true});
	}
});
